package com.situ.day5;

import org.junit.Test;

public class OOPDemo {
    @Test
    public void test1() {
        Student student1 = new Student();
        //对象.属性
        student1.id = 1;
        student1.name = "zhangsan";
        student1.age = 23;
        student1.gender = "男";
        System.out.println(student1.name);
        //对象.方法
        student1.study();
        System.out.println(student1);

        Student student2 = new Student();
        student2.id = 2;
        student2.name = "lisi";
        student2.age = 24;
        student2.gender = "女";
        System.out.println(student2.name);
        student2.study();
        System.out.println(student2);
    }

    @Test
    public void test2() {
        Student student = new Student();
        System.out.println(student.id);
        System.out.println(student.name);
        //System.out.println(student.flag);
        //System.out.println(student.array);

        int[] array1 = new int[3];
        Student[] array2 = new Student[3];
        boolean[] array3 = new boolean[3];
        System.out.println("OOPDemo.test2");
    }

    @Test
    public void test3() {
        Student student = new Student();
        student.id = 1;
        student.name = "zhangsan";
        student.age = 23;
        student.gender = "男";

        String str1 = student.getInfo();
        System.out.println(str1);

        String str2 = student.toString();
        System.out.println(str2);
        System.out.println(student.toString());
        System.out.println(student);
    }

    //NullPointerException空指针异常（引用数据类型）
    @Test
    public void test999() {
        Student student = null;
        System.out.println(student);//null
        // null.方法  null.属性
        //java.lang.NullPointerException: Cannot invoke "com.situ.day5.Student.study()"
        // because "student" is null
        student.study();
    }

}
